<?php

class moduleScanner
{

    function moduleScanner($mod_dir)
    {
        $this->mod_dir      = $mod_dir;
        $this->modules      = array();
        $this->descriptions = array();
        $this->getIndex();
        $this->readDescriptions();
        $this->modcount     = 0;
    }
   
    function getIndex()
    {
        $handle=opendir($this->mod_dir); 
        while ($file = readdir ($handle)) { 
            if ($file != "." && $file != "..") { 
                $this->modules[] = $file; 
            } 
        }
        closedir($handle);    
    }
   
    function readDescriptions()
    {
        if (is_array($this->modules))
        {
            foreach ($this->modules As $mod)
            {
                include ($this->mod_dir.$mod.'/etc/description.inc.php');
                $this->descriptions[$mod]['title'] = $title;
                $this->descriptions[$mod]['descr'] = $description;
                $this->descriptions[$mod]['href']  = "mod.php?module=$mod&instance=";
                $this->descriptions[$mod]['name']  = $mod;
            }
        }
    }
    
    function getNext()
    {
       	if (isset($this->modules[$this->modcount]) && isset($this->descriptions[$this->modules[$this->modcount]]))
	       	return $this->descriptions[$this->modules[$this->modcount++]];
    }
    
    function getByModule($mod)
    {
        return $this->descriptions[$mod];
    }
   

}

?>